<?
require_once("cms/core/helper/bean/Abstract.php");
require_once("cms/forum/om/TopicReplyPeer.php");
require_once("cms/forum/om/TopicPeer.php");

class PHP_CMS_View_Helper_Replies extends AbstractList {

    public function replies($form=null) {

        if($this->isInit)
            return $this;

        parent::init($form);

        $this->criteria->addJoin(TopicReplyPeer::TOPIC_ID, TopicPeer::TOPIC_ID);
        $this->criteria->add(TopicReplyPeer::TOPIC_ID, $form->getId());
        $this->criteria->setDistinct();

        return $this;

    }

    public function getTopic() {
        return TopicPeer::retrieveByPk($this->form->getId());
    }


    /**
     * Define the propel peer we are going to use to list
     * page items.
     */
    public function getMethod() {
        return "doSelectJoinTopic";
    }


    /**
     * Define the propel peer we are going to use to list
     * page items.
     */
    public static function getPeer() {
        return new TopicReplyPeer();
    }


    /**
     * Return the searchable fields for this list page.
     */
    public static function getFields() {
        return array(
            TopicReplyPeer::BODY,
            TopicReplyPeer::USERNAME,
            TopicReplyPeer::INSERT_DATE,
            TopicReplyPeer::MODIFIED_DATE
        );
    }
}
?>